$(function () {
        // //日期控件
		// var close = {
		// 	dateCell: "#closeTime",
		// 	format: 'YYYY-MM-DD hh:mm:ss',
		// 	isinitVal: false,
		// 	festival: false,
		// 	ishmsVal: false,
		// 	isTime: true,
		// 	maxDate: '2099-06-16 23:59:59'
		// };
		// jeDate(close);
      var item = GetQueryString("item");
      var sort = GetQueryString("sort");
      var eid = GetQueryString("eid");
      $("#item").val(item);
      $("#sort").val(sort);
      //根据ID查询数据
      var sel = $.Params.create();
     sel.ajax("get",getAdminIP()+"videos/"+eid,function(data){
        if(data.success){
            var val = data.result;
            $("#coverImg").attr("src",getIP()+"data/videoCover/"+val.videoImg);
             $("#expertImg").attr("src",getIP()+"data/expertImg/"+val.expertHeadImg);
             $("#expertName").val(val.expertName);
              $("#expertHospital").val(val.expertHospital);
              $("#title").val(val.title);
              getType(sort);
              $("#type").val(val.type);
              $("#videoUrl").val(val.videoUrl);
              $("#scoreC").val(val.scoreC);
              $("#videoDescription").val(val.videoDescription);
        }else{
            alert(data.msg);
        }
     })

   
    $("#addData").on("click", function () {
        $("#addForm").attr("action", getAdminIP()+"videos/"+eid);
        $("#addForm").submit();
    })

     //实时预览图片
    $("#videoImg").on("change", function (e) {
        var src, url = window.URL || window.webkitURL || window.mozURL, files = e.target.files;
      //  for (var i = 0, len = files.length; i < len; ++i) {
            var file = files[0];
            if (url) {
                src = url.createObjectURL(file);
            } else {
                src = e.target.result[0];
            }

            $("#coverImg").attr('src', src);
       // }
    });

     //实时预览图片
    $("#expertHeadImg").on("change", function (e) {
        var src, url = window.URL || window.webkitURL || window.mozURL, files = e.target.files;
       // for (var i = 0, len = files.length; i < len; ++i) {
            var file = files[0];

            if (url) {
                src = url.createObjectURL(file);
            } else {
                src = e.target.result[0];
            }

            $("#expertImg").attr('src', src);
       // }
    })
    //取消时
    $("#cancelAdd").on("click",function(){
        window.history.go(-1);
    })
})

 //加载类型列表 
       function getType(sort){
        var typeSel = $.Params.create();
         typeSel.ajax("get",getAdminIP()+"dictionarys/"+sort,function(data){
            if(data.success){
                var typeHtml = "<option value = '0'>请选择分类</option>";
                 $.each(data.result,function(i,val){
                    typeHtml+="<option value = '"+val.codeId+"'>"+val.codeDesc+"</option>";
                })
                 $("#type").html(typeHtml);
            }else{
                alert(data.msg);
            }
         })
       }